;;; special.el --- Customize Emacs for special projects

;; Copyright (C) 2010  Markus

;; Author: Markus <markus.prepens@googlemail.com>
;; Keywords: flymake

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;;

;;; Code:

(require 'flymake)



(defcustom my-flymake-c-compiler "gcc"
  "Flymakes compiler for C files."
  :type 'string
  :group 'my-customs)

(defcustom my-flymake-c++-compiler "g++"
  "Flymakes compiler for C++ files."
  :type 'string
  :group 'my-customs)

(defcustom my-flymake-c-option-list '("-Wall" "-I.." "-I../inc")
  "Flymakes C compiler options."
  :type '(repeat string)
  :group 'my-customs)


(defcustom my-flymake-c++-option-list '("-Wall" "-I.." "-I../inc")
  "Flymakes C++ compiler options."
  :type '(repeat string)
  :group 'my-customs)


;;;;;;;
;; C mode.
(defun flymake-c-init ()
  "Support function to get flymake-mode running for C files if no
makefile and make targt check-syntax exists. Required function
`flymake-get-c-cmdline' calls compiler directly."
  (flymake-simple-make-init-impl 'flymake-create-temp-inplace
                                 t
                                 t
                                 (file-name-nondirectory buffer-file-name)
                                 'flymake-get-c-cmdline))

(defun flymake-get-c-cmdline (source base-dir)
  "Function to return the complete command line to call the
compiler for C files."
  (list my-flymake-c-compiler
        (append my-flymake-c-option-list
                (list (concat base-dir source)))))

(push '(".+\\.c$" flymake-c-init) flymake-allowed-file-name-masks)
(push '(".+\\.h$" flymake-c-init) flymake-allowed-file-name-masks)



;;;;;;;
;; C++ mode.
(defun flymake-c++-init ()
  "Support function to get flymake-mode running for C++ files if
no makefile and make targt check-syntax exists. Required function
`flymake-get-c-cmdline' calls compiler directly."
  (flymake-simple-make-init-impl 'flymake-create-temp-inplace
                                 t
                                 t
                                 (file-name-nondirectory buffer-file-name)
                                 'flymake-get-c++-cmdline))

(defun flymake-get-c++-cmdline (source base-dir)
  "Function to return the complete command line to call the
compiler for C++ files."
    (list my-flymake-c++-compiler
        (append my-flymake-c++-option-list
                (list (concat base-dir source)))))

(push '(".+\\.cpp$" flymake-c++-init) flymake-allowed-file-name-masks)

(provide 'resource/flymake)
;;; special.el ends here
